//
//  BROrderDetailCell.m
//  Kexu
//
//  Created by IOS on 2023/7/17.
//

#import "BROrderDetailCell.h"

@implementation BROrderDetailCell


#pragma mark - UI --
- (void)setUI {
    
    
}

@end


@implementation BRODPayDeatilCell

/// 订单状态：0-初始化 1-租借中 2-待支付 3-已完成 4-已取消 5-调查中 6-已退款 7-已报失 8-购买pb
- (void)setCellType:(NSInteger)cellType {
    _cellType = cellType;
    
//    NSArray *hidds = @[@1];
//    if (cellType == 1 || cellType == 5) {
////        hidds = @[@2,@3,@4,@5,@6,@7];
//        hidds = @[@1,@2,@3,@4,@5,@6];
//    }else if (cellType == 7) {
//        hidds = @[@2,@3,@6];
//    }
//    
//    for (int i = 0; i < 7; i++) {
//       
//        BRODListView *cell = [self.stackV viewWithTag:2000 + i];
//        cell.hidden = [hidds containsObject:@(i)];
//        if ((cellType == 1 || cellType == 5) && i == 0) {
//            cell.line.hidden = YES;
//        }
//        if (cellType != 1 && i == 5) {
//            cell.line.hidden = YES;
//        }
//        if (i == 6) {
//            cell.line.hidden = YES;
//        }
//    }
}

- (void)br_text:(NSString *)text by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.textL.text = text;
    [cell.textL sizeToFit];
}

- (void)br_title:(NSString *)title by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.titleL.text = title;
    [cell.titleL sizeToFit];
}

- (void)br_title:(NSString *)title text:(NSString *)text by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    if (title.length != 0) cell.titleL.text = title;
    if (text.length != 0)  cell.textL.text = text;
}

- (void)br_cellHidden:(BOOL)hidden by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.hidden = hidden;
}

- (void)br_cellHiddenLine:(BOOL)hidden by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.line.hidden = hidden;
}

- (NSArray *)br_cellTypeOfList:(NSInteger)type {
  
    return @[];
}

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    [self.contView addSubview:self.stackV];
    [self.stackV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.offset(0);
    }];
    
    // 移除优惠券、充电卡等相关字段，只保留必要的字段
    [self br_addList:@[Localized(@"order_orderAmount"),
                       Localized(@"order_depositMethod"),
                       Localized(@"order_depositAmount"),
                       Localized(@"order_paymentAmount"),]];
    
}

- (void)br_addList:(NSArray *)titles {
    
    for (UIView *view in self.stackV.subviews) {
        [self.stackV removeArrangedSubview:view];
    }
    [self.stackV.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    for (int i = 0; i < titles.count; i++) {
        NSString *str = titles[i];
        BRODListView *cell = [[BRODListView alloc] init];
        if (i == titles.count - 1 ) {
            // 最后一个（实际支付金额）使用大字体
            cell.textL.font = [UIFont fontS:20];
            cell.line.hidden = YES;
        }
        
        [self.stackV addArrangedSubview:cell];
        cell.tag = 2000 + i;
        cell.titleL.text = str;
    }
}


- (UIStackView *)stackV {
    
    if (_stackV == nil) {
        
        _stackV = [[UIStackView alloc] init];
        _stackV.axis = UILayoutConstraintAxisVertical;
        
    }
    return _stackV;
}

@end

//---------------------
@implementation BRODRentCell


#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    [self.topView addSubview:self.topStack];
    [self.topStack br_addSubLabel:@[@"--",@"--",@"--"] font:[UIFont fontM:14] textColor:kColorTitle66B];
    [self.topStack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.top.offset(14);
        make.bottom.offset(-14);
    }];
    
    [self.bottomView addSubview:self.bottomStack];
    [self.bottomStack br_addSubLabel:@[@"--",@"--"] font:[UIFont fontM:14] textColor:kColorTitle66B];
    [self.bottomStack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.top.offset(14);
        make.bottom.offset(-14);
    }];
}

- (BRStackLabelView *)topStack {
    if (_topStack == nil) {
        _topStack = [[BRStackLabelView alloc] init];
    }
    return _topStack;
}

- (BRStackLabelView *)bottomStack {
    if (_bottomStack == nil) {
        _bottomStack = [[BRStackLabelView alloc] init];
    }
    return _bottomStack;
}

@end

@implementation BRODLostCell

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    [self.centView addSubview:self.centStack];
    [self.centStack br_addSubLabel:@[@"--",@"--",@"--"] font:[UIFont fontM:14] textColor:kColorTitle66B];
    [self.centStack mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.top.offset(14);
        make.bottom.offset(-14);
    }];
}

- (BRStackLabelView *)centStack {
    if (_centStack == nil) {
        _centStack = [[BRStackLabelView alloc] init];
    }
    return _centStack;
}


@end

@implementation BRODCompletedCell

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
//    [self.bottomView addSubview:self.bottomStack];
//    [self.bottomStack br_addSubLabel:@[@"--"]];
//    [self.bottomStack mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.offset(20);
//        make.right.offset(-20);
//        make.top.offset(14);
//        make.bottom.offset(-14);
//    }];
    
}

//- (BRStackLabelView *)bottomStack {
//    if (_bottomStack == nil) {
//        _bottomStack = [[BRStackLabelView alloc] init];
//    }
//    return _bottomStack;
//}


@end

@implementation BRODRentInfoCell

- (void)br_text:(NSString *)text by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.textL.text = text;
    [cell.textL sizeToFit];
}

- (void)br_title:(NSString *)title by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    cell.titleL.text = title;
    [cell.titleL sizeToFit];
}

- (void)br_title:(NSString *)title text:(NSString *)text by:(NSInteger)index {
    BRODListView *cell = [self.stackV viewWithTag:2000 + index];
    if (title.length != 0) cell.titleL.text = title;
    if (text.length != 0)  cell.textL.text = text;
}

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    [self.contView addSubview:self.stackV];
    [self.stackV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.offset(0);
    }];
    
    [self br_addList:@[Localized(@"order_freeDuration"),
                       Localized(@"order_usageDuration"),
                       Localized(@"order_costIncurred")]];
}

- (void)br_addList:(NSArray *)titles {
    
    for (UIView *view in self.stackV.subviews) {
        [self.stackV removeArrangedSubview:view];
    }
    [self.stackV.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    
    for (int i = 0; i < titles.count; i++) {
        NSString *str = titles[i];
        BRODListView *cell = [[BRODListView alloc] init];
        if (i == titles.count - 1) {
            // 最后一个（产生费用）隐藏分割线
            cell.line.hidden = YES;
        }
        
        [self.stackV addArrangedSubview:cell];
        cell.tag = 2000 + i;
        cell.titleL.text = str;
    }
}

- (UIStackView *)stackV {
    if (_stackV == nil) {
        _stackV = [[UIStackView alloc] init];
        _stackV.axis = UILayoutConstraintAxisVertical;
    }
    return _stackV;
}

@end


@implementation BRODBillingRuleCell

#pragma mark - UI --
- (void)setUI {
    [super setUI];
    
    self.ruleL = [BRToolsView br_label:@"--" textColor:kColorTitle66B font:[UIFont fontR:13]];
    self.ruleL.numberOfLines = 0;
    [self.contView addSubview:self.ruleL];
    [self.ruleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.top.offset(20);
        make.bottom.offset(-20);
    }];
    
}



@end
